import {createRouter, createWebHistory, RouteRecordRaw} from "vue-router";

const routes: Array<RouteRecordRaw> = [
    {
        path: '/',
        redirect: "/home"
    },
    {
        path: "/home",
        name: "Home",
        meta: {
            keepAlive: true,
            index: 1
        },
        component: () => import("@/views/ZJHome/ZJHome.vue")
    },
    {
        path: "/classify/:classifyId?",
        name: "Classify",
        meta: {
            keepAlive: true,
            index: 1
        },
        component: () => import("@/views/ZJClassify/ZJClassify.vue")
    },
    {
        path: "/shop-car",
        name: "ShopCar",
        meta: {
            keepAlive: true,
            index: 1
        },
        component: () => import("@/views/ZJShopCar/ZJShopCar.vue"),
        children: [
            {
                path: "payment",
                name: "ShopCarPayment",
                component: () => import("@/views/ZJShopCar/ShopCarPayment/ShopCarPayment.vue")
            }
        ]
    },
    {
        path: "/my",
        name: "My",
        meta: {
            keepAlive: true,
            index: 1
        },
        component: () => import("@/views/ZJMy/ZJMy.vue"),
        children: [
            {
                path: "enter",
                name: "MyEnter",
                meta: {
                    keepAlive: false
                },
                component: () => import("@/views/ZJMy/MyEnter/MyEnter.vue")
            },
            {
                path: "edit",
                name: "MyEdit",
                meta: {
                    keepAlive: false
                },
                component: () => import("@/views/ZJMy/MyEdit/MyEdit.vue")
            },
            {
                path: "address",
                name: "MyAddress",
                meta: {
                    keepAlive: true
                },
                component: () => import("@/views/ZJMy/MyAddress/MyAddress.vue"),
                children: [
                    {
                        path: "manage",
                        name: "MyAddressManage",
                        meta: {
                            keepAlive: false
                        },
                        component: () => import("@/views/ZJMy/MyAddress/AddressForm/AddressForm.vue")
                    }
                ]
            },
        ]
    },
    {
        path: "/goods",
        name: "Goods",
        meta: {
            keepAlive: false
        },
        component: () => import("@/views/ZJGoods/ZJGoods.vue"),
        children: [
            {
                path: "detail/:goodsId",
                name: "Detail",
                component: () => import("@/views/ZJGoods/GoodsDetail/GoodsDetail.vue")
            }
        ]
    },
    {
        name: "Payment",
        path: "/payment/:goodsId?",
        meta: {
            keepAlive: true
        },
        component: () => import("@/views/ZJPayment/ZJPayment.vue")
    },
    {
        name: "Order",
        path: "/order",
        component: () => import("@/views/ZJOrder/ZJOrder.vue"),
        children: [
            {
                name: "OrderDetail",
                path: "detail/:orderId?",
                component: () => import("@/views/ZJOrder/OrderDetail/OrderDetail.vue")
            }
        ]
    },
    {
        path: "/:chapters+",
        redirect: "/home"
    }
]
const router = createRouter({
    history: createWebHistory(),
    routes
})
export default router
